package com.jackeysun.common_kit

/**
 *   Created by sunxunchao on 2022/3/24.
 */

fun main() {

    val persons = listOf<Person>(
        Person("jack3", 29),
        Person("jack4", 8),
        Person("jack2", 12),
        Person("jack5", 30),
        Person("jack6", 90),
        Person("jack1", 20)
    )


    persons.sortedByDescending { it.age }
        .forEach {
            println(it.toString())
        }

//    persons.sortedWith { o1, o2 ->
//        if (o1.age > o2.age) 1 else if (o1.age == o2.age) 0 else -1
//    }.forEach {
//        println(it.toString())
//    }
}


data class Person(val name: String, val age: Int)